<?  //print_r($post_wall); ?>
 <?php //print_r($comment); ?>
<?php //print_r($fb); ?>
<div class="ui-grid-solo">
			<div class="ui-block-a content">
      			<div class="ui-body ui-body-a">
      				<div class="ui-block-a">
				    	<div class="ui-bar" style="height:60px;width:50px">
				    		<img src="<?php echo base_url().$post_wall[0]['fb_pic_poster']; ?>" style="width:50px;height:50px;">
				    	</div>
				    </div>
				    <div class="ui-grid-solo">
				    	<div class="ui-bar" style="height:60px">
				    		<div id="post_name" style="margin-top:5px"><h1><?php echo $post_wall[0]['fb_username_poster']." >".$post_wall[0]['fb_username_wall']; ?></h1></div>
				    		<div id="post_time" style="margin-top:5px"><?php echo $post_wall[0]['post_timestamp']; ?></div>
				    	</div>
				    </div>
				</div>
				<div class="ui-body ui-body-a ui-coner-all" id='comment_id'>
						<div>
						<?php 
							if($post_wall[0]['post_pic']!=null){
								echo "<div id='imgcontent'>";
								echo "<img src='".base_url().$post_wall[0]['post_pic']."' style='width:60%'>";
								echo "</div>";
							}
							if($post_wall[0]['post_content']!=null){
							 	echo "<p>".$post_wall[0]['post_content']."</p>";
							}
						?>
						</div>
						<a href="#" >like</a>
				</div>
				<div class="ui-bar ui-bar-a ui-coner-all" >
					<div data-type="horizontal" class="ui-grid-a">
						 <div>22 like</div>
						 <div style="border:1px solid gray" ></div><p>
						 <?php for($i=0;$i<sizeof($comment);$i++){ ?>
						 	<div >
						 		<div  class="ui-block-a" style="width:60px">
						 	 	<div style="height:50px;width:50px">
						    		<img src='<?php echo base_url().$comment[$i]['fb_pic_com']; ?>' style="width:50px;height:50px;">
						    	</div>
						 	 </div>
							 
							 	<div class="ui-grid-solo">
							 		<div class="ui-block-a">
							 			<a href=""><?php  echo $comment[$i]['fb_username_com']; ?></a>
							 			<div style="word-wrap:break-word"><?php  echo $comment[$i]['com_content']; ?></div>
							 		</div>
							 		<div class="ui-block-a">
							 			<div><?php  echo $comment[$i]['com_timestamp']; ?> · 
							 				<a onclick='click_com_like(<?php echo $comment[$i]['com_id']; ?>)'>
							 				<?php 
							 					if($comment[$i]['liked']=='FALSE'){
							 						echo "<span id='com_like".$comment[$i]['com_id']."'>like</span>";
							 					}else{
							 						echo "<span id='com_like".$comment[$i]['com_id']."'>unlike</span>";
							 					}
							 				?>
							 				</a>
							 			</div>
							 		</div>
							 	</div>
						 	</div>
						 	<?php } ?>
						 	<div id="comment_update">
						 	</div>
						 	
						 	
							 <form>
							 		<textarea data-role="none"  rows="3" id="area-comment" class="ui-input-text ui-shadow-inset ui-body-inherit ui-corner-all "  placeholder="Write a comment.." ></textarea>
							 </form>
						 </div>
					</div>
				</div>
				<!-- comment -->
				<div >
					
				</div>
      		</div>
      		<script> 
      				var date = new Date();
      				if(date.getMonth()+1>10){
      					var month = date.getMonth()+1;
      				}else{
      					var month = '0'+(date.getMonth()+1);
      				}
      				if(date.getDate()>10){
      					var day = date.getDate();
      				}else{
      					var day = '0'+(date.getDate());
      				}
      				var nowhour = date.getUTCHours()+7;
      				var nowdate = date.getFullYear()+'-'+month+'-'+day;
      				var nowtime =nowhour+':'+date.getUTCMinutes()+':'+date.getUTCSeconds();
      				var now_time =nowdate+' '+nowtime;

      				var fb_pic = "<?php echo $fb[0]['fb_pic'];?>";
      				var fb_username = "<?php echo $fb[0]['fb_username'];?>";
					$( "#area-comment" ).keydown(function( event ) {
	  				if ( event.which == 13 ) {
						   $.ajax({
					            type: "POST",
					            url: "<?php echo site_url('home/ajax_comment');?>",
					            data: {
					            		"post_id" : <?php echo $post_wall[0]['post_id'];?>,
					            		"com_content" : $("#area-comment").val(),
					            		"fb_id_wall" : <?php echo $post_wall[0]['fb_id_wall'];?>,
					            		"fb_id_com" : <?php echo $fb[0]['fb_id'];?>
					             },
					            success: function(html){
					  					if(html="TRUE"){
					  							$.ajax({
											            type: "POST",
											            url: "<?php echo site_url('home/ajax_updatecomment');?>",
											            data: {
											            		"com_content" : $("#area-comment").val(),
											            		"fb_pic" : fb_pic,
											            		"fb_username" : fb_username,
											            		"com_time" : now_time

											             },
											            success: function(html){
											  					$('#comment_update').append(html);
											  					$('#area-comment').val('');
											            }
											        });	
					  					}else{
					  						alert("False");
					  					}
					            }
					        });	
						}
					});
					function click_com_like(num){
							var id = <?php echo $fb[0]['fb_id'];?>;
							if($("#com_like"+num).html() == 'like'){
								$.ajax({
										type: "POST",
										url: "<?php echo site_url('home/ajax_insert_likec');?>",
										data: {
											    "com_id" : num,
											    "fb_id" : id,
											   },
									 	success: function(html){
									 		$("#com_like"+num).html('unlike');
										}
									   });
								
							}else{
									$.ajax({
										type: "POST",
										url: "<?php echo site_url('home/ajax_delete_likec');?>",
										data: {
											    "com_id" : num,
											    "fb_id" : id,
											   },
									 	success: function(html){
									 		$("#com_like"+num).html('like');
										}
									   });
							}
					}
      		</script>